<?php
namespace app\api\controller\job;
use app\common\annotation\ApiNodeAnnotation;
use app\common\controller\ApiBase;
use think\Db;

/**
 * @ApiNodeAnnotation(
 *     title="职位筛选器Api",
 *     parent="default",
 *     is_release=0,
 *     auth=1,
 * )
 */class Index extends ApiBase
{
    /**
     * @ApiNodeAnnotation(
     *     title="职位地区列表",
     *     parent="api/job.index",
     *     is_release=1,
     *     auth=1,
     * )
     */
    public function arealist($page=1,$limit=15)
    {
        $areaList = [
            [
                "name" => "不限"
            ],
            [
                "name" => "省直"
            ],
            [
                "name" => "贵阳"
            ],
            [
                "name" => "遵义"
            ],
            [
                "name" => "毕节"
            ],
            [
                "name" => "铜仁"
            ],
            [
                "name" => "安顺"
            ],
            [
                "name" => "六盘水"
            ],
            [
                "name" => "黔东南"
            ],
            [
                "name" => "黔西南"
            ],
            [
                "name" => "黔南"
            ]
        ];
        $this->success('职位筛选器地区列表','',$areaList);
    }


    /**
     * @ApiNodeAnnotation(
     *     title="职位分类列表",
     *     parent="api/job.index",
     *     is_release=1,
     *     auth=1,
     * )
     */
    public function categorylist($page=1,$limit=15)
    {
        $categoryList = [
            [
                "name" => "不限"
            ],
            [
                "name" => "选调生"
            ],
            [
                "name" => "公务员"
            ],
            [
                "name" => "人名警察"
            ],
            [
                "name" => "事业单位"
            ],
        ];
        $this->success('职位筛选器分类列表','',$categoryList);
    }

    /**
     * @ApiNodeAnnotation(
     *     title="职位学历列表",
     *     parent="api/job.index",
     *     is_release=1,
     *     auth=1,
     * )
     */
    public function shcoolinglist($page=1,$limit=15)
    {
        $categoryList = [
            [
                "name" => "不限"
            ],
            [
                "name" => "中专"
            ],
            [
                "name" => "大专"
            ],
            [
                "name" => "本科"
            ],
            [
                "name" => "研究生"
            ],
            [
                "name" => "博士"
            ],
            [
                "name" => "硕士"
            ],
        ];
        $this->success('职位筛选器分类列表','',$categoryList);
    }

    /**
     * @ApiNodeAnnotation(
     *     title="职位政治面貌",
     *     parent="api/job.index",
     *     is_release=1,
     *     auth=1,
     * )
     */
    public function facelist($page=1,$limit=15)
    {
        $faceList = [
            [
                "name" => "不限"
            ],
            [
                "name" => "中共党员"
            ],
            [
                "name" => "预备党员"
            ],
            [
                "name" => "民盟盟员或群众"
            ],
        ];
        $this->success('职位筛选器争政治面貌列表','',$faceList);
    }

    /**
     * @ApiNodeAnnotation(
     *     title="获取部门，职位，列表信息",
     *     parent="api/job.index",
     *     is_release=1,
     *     auth=1,
     * )
     */
    public function unitlist($columnid=0,$page=1,$limit=10000)
    {
        $where = [];
        $group = 'department';
        $field = 'department';
        $param = $this->request->param();


        if($columnid) array_push($where,['column_id','eq',$columnid]);

        //根据地区获取单位并去重
        if(isset($param['area']))
        {
            array_push($where,['area','like',"%{$param['area']}%"]);
            $group = 'department';
            $field = 'department,id,job_name,job_code';
        }
        //根据地区,单位胡获取相关职位并去重
        if(isset($param['department']))
        {
            array_push($where,['department','eq',$param['department']]);
            $group = 'job_name,job_code';
            $field = 'job_name,job_code,id';
        }

        $unitList =  Db::connect("xxn_config")->table("cp_jobtable")
           ->page($page)
           ->limit($limit)
           ->where($where)
           ->field($field)
           ->group($group)
           ->select();

        $this->success('职位筛选器部门列表','',$unitList);
    }

    /**
     * @ApiNodeAnnotation(
     *     title="职位筛选器联系电话",
     *     parent="api/job.index",
     *     is_release=1,
     *     auth=1,
     * )
     */
    public function phone()
    {
        $phone = '13765895164';
        $this->success("success",'',$phone);
    }
}